/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.commands.diagram;

import com.cea.papyrus.diagraminterchange2.di2.Diagram;

/**
 * 
 */
public class CloseDiagramCommand extends org.eclipse.gef.commands.Command
{
	
	/**
	 * 
	 */
	protected Diagram diagram;

	/**
	 * 
	 * 
	 * @param diagram 
	 */
	public CloseDiagramCommand(Diagram diagram) {
		super("CloseDiagramCommnand");
		this.diagram = diagram;
	}

	/**
	 * 
	 */
	@Override
	public void execute() {
		redo();
	}

	/**
	 * 
	 */
	@Override
	public void redo() {
		diagram.setIsVisible(false);
	}


	/**
	 * 
	 */
	@Override
	public void undo() {
		diagram.setIsVisible(true);
	}

	/**
	 * This method tests if the element is allowed to be created.
	 * 
	 * @return 
	 */
	@Override
	public boolean canExecute() {
        return diagram.isIsVisible();
	}
}
